﻿@page "/Admin/Profiles"
@attribute [TabItemOption(Text = "个人中心", Icon = "fa-solid fa-suitcase")]

<div class="tab-scroll-body">
    <AdminCard HeaderText="基本资料" AuthorizeKey="SaveDisplayName">
        <AdminAlert Text="演示系统禁止更改管理员显示名称" IsShow="IsDemo" />
        <ValidateForm OnValidSubmit="OnSaveDisplayName" Model="CurrentUser">
            <div class="row g-3 form-inline">
                <div class="col-12 col-sm-6">
                    <Display @bind-Value="@CurrentUser.UserName" />
                </div>
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@CurrentUser.DisplayName" Readonly="IsDemo" />
                </div>
                <Block Condition="!IsDemo">
                    <div class="col-12 justify-content-end">
                        <Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="保存" />
                    </div>
                </Block>
            </div>
        </ValidateForm>
    </AdminCard>

    <AdminCard HeaderText="修改密码" AuthorizeKey="SavePassword">
        <AdminAlert Text="演示系统禁止更改管理员密码" IsShow="IsDemo" />
        <ValidateForm OnValidSubmit="OnSavePassword" Model="CurrentUser">
            <div class="row g-3 form-inline">
                <div class="col-12 col-sm-6">
                    <BootstrapInput @bind-Value="@CurrentUser.Password" DisplayText="原密码" Readonly="IsDemo" />
                </div>
                <div class="col-12 col-sm-6 d-none d-sm-block">
                </div>
                <div class="col-12 col-sm-6">
                    <BootstrapPassword @bind-Value="@CurrentUser.NewPassword" Readonly="IsDemo" />
                </div>
                <div class="col-12 col-sm-6">
                    <BootstrapPassword @bind-Value="@CurrentUser.ConfirmPassword" Readonly="IsDemo" />
                </div>
                <Block Condition="!IsDemo">
                    <div class="col-12 justify-content-end">
                        <Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="保存" />
                    </div>
                </Block>
            </div>
        </ValidateForm>
    </AdminCard>

    <AdminCard HeaderText="默认应用" AuthorizeKey="SaveApp">
        <AdminAlert Text="演示系统禁止更改默认应用" IsShow="IsDemo" />
        <div class="row g-3 form-inline">
            <div class="col-12 col-sm-6">
                <Dropdown Items="Apps" @bind-Value="CurrentUser.App" />
            </div>
            <Block Condition="!IsDemo">
                <div class="col-12 col-sm-6 justify-content-end">
                    <Button Icon="fa-solid fa-floppy-disk" Text="保存" OnClickWithoutRender="OnSaveApp" />
                </div>
            </Block>
        </div>
    </AdminCard>

    <AdminCard HeaderText="网站样式" AuthorizeKey="SaveApp">
        <AdminAlert Color="Color.Info">
            <span>注意：本设置将覆盖 <b><TabLink Url="/Admin/Settings" Text="网站设置" Icon="fa-solid fa-flag">网站设置</TabLink></b> 中设置的网站样式</span>
        </AdminAlert>
        <div class="row g-3 form-inline">
            <div class="col-12 col-sm-6">
                <Dropdown Items="Themes" @bind-Value="CurrentUser.Css" />
            </div>
            <Block Condition="!IsDemo">
                <div class="col-12 col-sm-6 justify-content-end">
                    <Button Icon="fa-solid fa-floppy-disk" Text="保存" OnClickWithoutRender="OnSaveTheme" />
                </div>
            </Block>
        </div>
    </AdminCard>

    <AdminCard HeaderText="个人头像" AuthorizeKey="SaveIcon">
        <div class="row g-3 form-inline">
            <div class="col-12 col-sm-6">
                <CardUpload TValue="string" IsSingle="true" DefaultFileList="PreviewFileList" OnChange="OnSaveIcon" OnDelete="OnDeleteIcon" />
            </div>
        </div>
    </AdminCard>
</div>
